from dateutil.relativedelta import relativedelta
import datetime


birth_date_str = '2017-12-05'
try:
    birth_date = datetime.datetime.strptime(birth_date_str, '%Y-%m-%d')
    current_date = datetime.datetime.now()
            # 使用relativedelta计算年龄差值
    diff = relativedelta(current_date, birth_date)
    print(f"{diff.years}年{diff.months}月{diff.days}天")
except ValueError:
    print("日期格式错误，请重新输入。")